package com.service.${packageName};

import com.dao.${packageName}.${moduleName ? cap_first}Mapper;
import com.entity.common.ApiResult;
import com.entity.${packageName}.${moduleName ? cap_first};
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by System on ${createDate}.
 */
@Service
public class ${moduleName ? cap_first}Service {

    @Autowired
    private ${moduleName ? cap_first}Mapper ${moduleName}Mapper;

    public List<${moduleName ? cap_first}> getPageList(${moduleName ? cap_first} ${moduleName}){
        return ${moduleName}Mapper.getPageList(${moduleName});
    }

    public ApiResult add${moduleName ? cap_first}(${moduleName ? cap_first} ${moduleName}) {
        int num = ${moduleName}Mapper.insertSelective(${moduleName});
        return  new ApiResult(num);
    }

    public ApiResult get${moduleName ? cap_first}ById(Long id) {
        ${moduleName ? cap_first} ${moduleName} = ${moduleName}Mapper.selectByPrimaryKey(id);
        return new ApiResult(true,"获取数据成功！",${moduleName});
    }

    public ApiResult edit${moduleName ? cap_first}(${moduleName ? cap_first} ${moduleName}) {
        int num = ${moduleName}Mapper.updateByPrimaryKeySelective(${moduleName});
        return  new ApiResult(num);
    }

    public ApiResult delete${moduleName ? cap_first}(Long id) {
        int num = ${moduleName}Mapper.deleteByPrimaryKey(id);
        return  new ApiResult(num);
    }
}
